<?php 
require_once("../include/conn.php");
$name=trim($_REQUEST["name"]);
$url=trim($_REQUEST["url"]);
$description=trim($_REQUEST["description"]);
$tdate=date("Y-m-d");
$leid=trim($_REQUEST["leid"]);
$pic=trim($_REQUEST["pic"]);
$isshow=trim($_REQUEST["isshow"]);
if($_REQUEST["action"] == "pack"){				
	
	$sql_dz="delete from `$tb_lk` where `id`=".$id;
	
	$cn_dz = mysql_db_query($db_name,$sql_dz); 	
	self("删除操作已成功！","link_mange.php");
										
}else{

	if($name!="" && $url!="" ){
			if($_REQUEST["action"] == "update"){				
					if(!empty($_REQUEST["id"]))
					{			
						$id=$_REQUEST["id"];
						
						if(isset($_REQUEST["pic"]) && strlen($_REQUEST["pic"])>15){
							$pic1=$_REQUEST["pic"];
							$pic2=basename($pic1); 
							$pic3=explode(".",$pic2);
							if($pic3[1]=="gif" || $pic3[1]=="jpg"  || $pic3[1]=="jpeg"  || $pic3[1]=="bmp"  || $pic3[1]=="png" )
							$pic=$pic1;
							else $pic="";
							//$content=changimgwidth($content,$pic);	
						}
						
						$sql_dz="UPDATE `$tb_lk` SET ";
						
						$sql_dz.=" `name` = '$name',`description` = '$description',`tdate` = '$tdate',`pic` = '$pic',`url` = '$url',`isshow` = '$isshow',`leid` = '$leid'";				
						
						$sql_dz.=" WHERE `id` = '$id'";					
						 //echo $sql_dz;
						$cn_dz = mysql_db_query($db_name,$sql_dz); 					
					}else{				
						//self("操作已成功！","admin_index.php");		
					}		
			}
			if($_REQUEST["action"] == "add"){				
						
						$sql_dz="insert into `$tb_lk` ";
						
						$sql_dz.="( `name` ,`description`,`tdate`,`pic` ,`url` ,`isshow` )";				
						if(isset($_REQUEST["pic"]) && strlen($_REQUEST["pic"])>15){
							$pic1=$_REQUEST["pic"];
							$pic2=basename($pic1); 
							$pic3=explode(".",$pic2);
							if($pic3[1]=="gif" || $pic3[1]=="jpg"  || $pic3[1]=="jpeg"  || $pic3[1]=="bmp"  || $pic3[1]=="png" )
							$pic=$pic1;
							else $pic="";
							//$content=changimgwidth($content,$pic);	
						}
						$sql_dz.=" values (  '$name', '$description', '$tdate', '$pic', '$url', '$isshow')";					
						//echo $sql_dz;
						$cn_dz = mysql_db_query($db_name,$sql_dz); 						
			}
		
			
			self("操作已成功！","link_mange.php");		 
	}
	else{
		echo ("<script type='text/javascript'> alert('填写资料不完整！');history.go(-1);</script>");
	}
	
}
?>